/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	VertexElementSizes.h
*
*	Description -	Contains the sizes of each type of vertex element.
*
*	Comments	-	
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	09/05/2012	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_INDEX_SOURCE_H_
#define _PSX_INDEX_SOURCE_H_

#include "PulseSTD.h"
#include "GraphicsTypes.h"

namespace Pulse
{
	class IndexSource
	{
	public:

		IndexSource( void );

		IndexSource( SIZE_T32 count, BOOL bUse16Bit = TRUE );

		~IndexSource( void );

		EErrorCode::Type Initialize( SIZE_T32 count, BOOL bUse16Bit = TRUE );

		const BOOL Is16BitIndices( void ) const { return m_bUse16Bit; }

		const SIZE_T32 GetNumIndices( void ) const { return m_numIndices; }

		void * GetBuffer( void ) { return m_pBuffer; }

		UINT16 * GetAs16BitIndices( void ) { return m_pIndices16; }

		UINT32 * GetAs32BitIndices( void ) { return m_pIndices32; }

		//UPOS_T32 AddIndex( UINT16 index );

		//UPOS_T32 AddIndex( UINT32 index );

		//UPOS_T32 AddIndices( SIZE_T32 numIndices, UINT16 *pIndices );

		//UPOS_T32 AddIndices( SIZE_T32 numIndices, UINT32 *pIndices );

	private:

		EErrorCode::Type ResizeBuffer( SIZE_T32 count );

		void ClearBuffer( void );

		void Set16BitUsage( BOOL bUse16Bit ) { m_bUse16Bit = bUse16Bit; }

		//BOOL CheckCanAdd( BOOL bAddingAs16Bit, SIZE_T32 numIndices = 1 );

	private:

		IndexSource( IndexSource & );
		IndexSource & operator = ( IndexSource & );

	private:

		SIZE_T32 m_numIndices;
		BOOL	 m_bUse16Bit;
		//UPOS_T32 m_writeMarker;

		union
		{
			BYTE *m_pBuffer;
			UINT16 *m_pIndices16;
			UINT32 *m_pIndices32;
		};

	};
}

#endif /* _PSX_INDEX_SOURCE_H_ */